package utilities;
import gui.polish.PolishPanel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Timer;

import javax.swing.JOptionPane;

import java.util.*;

import clients.RPCClient;

// This class is a Timer class , it schedules a task of updating pellets once a day in order to know how many days been sine there where changed . 
public class UpdatePelletsPerDayTimer  {

	private long pelletsNumber;
	private RPCClient myRPCClient;
	private PolishPanel myPolishPanel;
	private Timer timer;
	
	public UpdatePelletsPerDayTimer (int day)
	{
		timer = new Timer();
		timer.schedule(new RemindTask(), 0,day*1000*60*60*24);
	}
	
	class RemindTask extends TimerTask
	{

		@Override
		public void run() {
			//if(PolishPanel.youCanUpdatePelletsDB==true)
			//System.out.println("im here ");
			//
			ArrayList<Object>message=new ArrayList<>();
			ArrayList<Object>respond=new ArrayList<>();
			message.add("updatingPellets");
			try{
				myRPCClient = new RPCClient();
				respond = myRPCClient.call(message);
			}
			catch(Exception e){
				//e.printStackTrace();
			}
			//
			
		}
		
	}


}
